package cn.swh.guguanjia.controller;

import cn.swh.guguanjia.entity.Qualification;
import cn.swh.guguanjia.entity.QualificationCondition;
import cn.swh.guguanjia.entity.Result;
import cn.swh.guguanjia.service.QualificationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

@RestController
//manager/qualification/index   对应列表页请求
@RequestMapping("/mapper/qualification")
public class QualificationController {

    /**
     * @Description
     * @Params
     * @return
     **/


    @Autowired
    QualificationService service;


    @RequestMapping({"/index", "/index.html"})
    public ModelAndView index() {
        return new ModelAndView("/qualification/index.html");
    }


    //qualification
    @RequestMapping("selectPage/{pageNum}/{pageSize}")
    public Result selectPage(@PathVariable("pageNum") int pageNum, @PathVariable("pageSize") int pageSize,
                             QualificationCondition condition) {
        return new Result(service.selectPage(pageNum, pageSize, condition));
    }

    @RequestMapping({"/toUpdate", "/update.html"})
    public ModelAndView toUpdate() {
        return new ModelAndView("/qualification/update.html");
    }

    @RequestMapping(value = "/doUpdate", method = RequestMethod.PUT)
    public Result doUpdate(@RequestBody Qualification qualification) {
        return new Result(service.updateByPrimaryKeySelective(qualification));
    }

    @RequestMapping("selectOne/{id}")
    public Result selectOne(@PathVariable long id) {
        return new Result(service.selectByPrimaryKey(id));
    }

}
